package com.smh.a21ThreadPoolDemo1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo1 {
    public static void main(String[] args) throws InterruptedException {

        ExecutorService es = Executors.newCachedThreadPool();//无上限的线程池
        ExecutorService ex2 = Executors.newFixedThreadPool(3);

        MyRunnable runnable = new MyRunnable();

        ex2.submit(runnable);
        ex2.submit(runnable);
        ex2.submit(runnable);
        ex2.submit(runnable);
        ex2.submit(runnable);
        ex2.submit(runnable);

        ex2.shutdown();

     /*   es.submit(runnable);//提交任务
        Thread.sleep(1000);
        es.submit(runnable);//提交任务
        Thread.sleep(1000);
        es.submit(runnable);//提交任务
        Thread.sleep(1000);
        es.submit(runnable);//提交任务
        es.submit(runnable);//提交任务

        es.shutdown();//销毁线程池*/

    }
}
